﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>WinMove - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The WinMove function changes the position and/or size of the specified window." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>WinMove</h1>

<p>Changes the position and/or size of the specified window.</p>

<pre class="Syntax"><span class="func">WinMove</span> X, Y <span class="optional">, Width, Height, WinTitle, WinText, ExcludeTitle, ExcludeText</span></pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>X, Y</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
    <p>The X and Y coordinates (in pixels) of the upper left corner of the target window's new location. The upper-left pixel of the screen is at 0, 0.</p>
    <p>If these are the only parameters given with the function, the <a href="../misc/WinTitle.htm#LastFoundWindow">Last Found Window</a> will be used as the target window.</p>
    <p>Otherwise, X and/or Y can be omitted, in which case the current position is used.</p>
  </dd>

  <dt>Width, Height</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
    <p>The new width and height of the window (in pixels). If either is omitted or blank, the size in that dimension will not be changed.</p>
  </dd>

  <dt>WinTitle</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a>, <a href="../Concepts.htm#numbers">整数</a>或<a href="../Objects.htm">对象</a></p>
    <p>识别目标窗口的窗口标题或其他条件. 请参阅 <a href="../misc/WinTitle.htm">WinTitle</a>.</p>
  </dd>

  <dt>WinText</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>如果存在, 此参数必须是目标窗口的单个文本元素的子字符串(和内置的 Window Spy 工具显示的一样). 如果 <a href="DetectHiddenText.htm">DetectHiddenText</a> 为 ON, 那么会检测隐藏文本元素.</p>
  </dd>

  <dt>ExcludeTitle</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>标题中含有此参数值的窗口将被排除.</p>
  </dd>

  <dt>ExcludeText</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>文本中含有此参数值的窗口将被排除.</p>
  </dd>

</dl>

<h2 id="Remarks">备注</h2>
<p>If <em>Width</em> and <em>Height</em> are small (or negative), most windows with a title bar will generally go no smaller than 112 x 27 pixels (however, some types of windows may have a different minimum size). If <em>Width</em> and <em>Height</em> are large, most windows will go no larger than approximately 12 pixels beyond the dimensions of the desktop.</p>
<p>Negative values are allowed for the x and y coordinates to support multi-monitor systems and to allow a window to be moved entirely off screen.</p>
<p>Although WinMove cannot move minimized windows, it can move hidden windows if <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> is on.</p>
<p>The speed of WinMove is affected by <a href="SetWinDelay.htm">SetWinDelay</a>.</p>
<p>窗口标题和文本是区分大小写的. 除非 <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> 被打开, 否则不会检测隐藏窗口.</p>

<h2 id="Related">相关</h2>
<p><a href="ControlMove.htm">ControlMove</a>, <a href="WinGetPos.htm">WinGetPos</a>, <a href="WinHide.htm">WinHide</a>, <a href="WinMinimize.htm">WinMinimize</a>, <a href="WinMaximize.htm">WinMaximize</a>, <a href="Win.htm">Win 函数</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExLastFound">
<p><a href="#ExLastFound">#1</a></p>
<pre>Run "calc.exe"
WinWaitActive "Calculator"
WinMove 0, 0 <em>; Move the window found by WinWait to the upper-left corner of the screen.</em></pre>
</div>

<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#2</a></p>
<pre>MyGui := Gui.New("ToolWindow -Sysmenu Disabled", "The clipboard contains:")
MyGui.Add("Text",, A_Clipboard)
MyGui.Show("w400 h300")
WinMove 0, 0,,, MyGui.Title <em>; Move the splash window to the top left corner.</em>
MsgBox "Press OK to dismiss the Gui window"
MyGui.Destroy</pre>
</div>

<div class="ex" id="ExCenter">
<p><a href="#ExCenter">#3</a>: The following <a href="../Functions.htm">function</a> centers the specified window on the screen:</p>
<pre>CenterWindow(WinTitle)
{
    WinGetPos ,, Width, Height, WinTitle
    WinMove (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2),,, WinTitle
}</pre>
</div>

</body>
</html>